package com.wzz.seckillone.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzz.seckillone.mapper.GoodsMapper;
import com.wzz.seckillone.pojo.Goods;
import com.wzz.seckillone.service.GoodsService;
import com.wzz.seckillone.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-11-08
 */
@Service
@Transactional
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public List<GoodsVo> findGoodsVo() {
        return goodsMapper.fineGoodsVo();
    }

    @Override
    public GoodsVo findGoodsVoById(String id) {
        GoodsVo goods = goodsMapper.findGoodsVoById(id);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        simpleDateFormat.format(goods.getStartDate());
        return goods;
    }

    @Override
    public Goods getGoodsByGoodsId(String goodsId) {
        return goodsMapper.getGoodsByGoodsId(goodsId);
    }
}
